package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.TSupplier;
import com.ruoyi.system.service.TSupplierService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TSupplier)表控制层
 *
 * @author makejava
 * @since 2025-01-01 20:37:34
 */
@RestController
@RequestMapping("tSupplier")
public class TSupplierController extends BaseController     {
    /**
     * 服务对象
     */
    @Resource
    private TSupplierService tSupplierService;

    /**
     * 分页查询
     *
     * @param tSupplier 筛选条件
     * @return 查询结果
     */
    @GetMapping
    public TableDataInfo queryByPage(TSupplier tSupplier) {
        return getDataTable(this.tSupplierService.queryByPage(tSupplier));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<TSupplier> queryById(@PathVariable("id")Integer  id) {
        return ResponseEntity.ok(this.tSupplierService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param tSupplier 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<TSupplier> add(TSupplier tSupplier) {
        return ResponseEntity.ok(this.tSupplierService.insert(tSupplier));
    }

    /**
     * 编辑数据
     *
     * @param tSupplier 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<TSupplier> edit(TSupplier tSupplier) {
        return ResponseEntity.ok(this.tSupplierService.update(tSupplier));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.tSupplierService.deleteById(id));
    }

}

